<?php

echo 'start-time:'.date('Ymd H:i:s');
$urls = [
	'http://www.baidu.com',
	'http://news.baidu.com',
	'http://tieba.baidu.com'
];

$workers = [];


foreach ($urls as $k => $val) {
	
	$process = new Swoole_process(function($pro) use ($val){

		$content = getUrlContent($val);
		$pro->write($content);

	},true);

	$pid = $process->start();

	$workers[$pid] = $process;
}



foreach ($workers as $k => $val) {
	
	echo $val->read().PHP_EOL;
}


function getUrlContent($url){

	sleep(2);
	return $url;
}

echo 'end-time:'.date('Ymd H:i:s');